#include "childwindow.h"
#include <QDebug>
#include <QTextEdit>

/*
子窗口
*/
ChildWindow::ChildWindow(QString path, MainWindow *p) : QWidget(p), multiple(1)
{
    setAttribute(Qt::WA_DeleteOnClose);
    setStyleSheet("background-color:gray");
    this->resize(p->size());

    pdf = new PDFKit(path);

    leftWidget = new Naviview(pdf);
    rightWidget = new DocWidget(pdf, this);
    connect(rightWidget->scrollbar, &QScrollBar::valueChanged, this, &ChildWindow::page_change);

    splitter = new QSplitter(this);
    splitter->resize(this->size());
    splitter->addWidget(leftWidget);
    splitter->addWidget(rightWidget);
    splitter->setOpaqueResize(true);//默认的true
    splitter->setStretchFactor(1,1);
    splitter->setAutoFillBackground(true);
    splitter->setHandleWidth(1);
}

ChildWindow::~ChildWindow()
{

}

void ChildWindow::paintEvent(QPaintEvent *)
{

}


void ChildWindow::resizeEvent(QResizeEvent *)
{
 //   qDebug() << "aaaa";
    splitter->resize(this->size());
}

void ChildWindow::gotoPage(int page)
{
    rightWidget->gotoPage(page);
}

int ChildWindow::getCurrentPage()
{
    return rightWidget->getCurrentPage();
}

void ChildWindow::changeImageSize(int flag)
{
    rightWidget->changeImageSize(flag);
}

void ChildWindow::refreshWidget()
{
    rightWidget->refreshWidget();
}


